﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using messageboard.bll;

namespace messageboard
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //分配匿名ID
            
                Session["id"] = 1;
                Session["name"] = "匿名";
           
            
            
            
        }
        //_来_自_5_1_a_s_p__x
        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = TextBox1.Text;
            string pw = TextBox2.Text;
            UserBll bll = new UserBll();
            bool su = bll.selectname(name, pw);
            if (su)//判断用户名密码是否正确
            {
                Session["name"] = name;
               int id= bll.getid(name);
                Session["id"] = id;
                //判断是否管理员登录
                if (name=="admin")
                {
                    Response.Redirect("~/admin/messagemanage.aspx");//转到留言管理页面
                }
                else
                {
                    Response.Redirect("~/message.aspx");//转到留言页面
                } 
            }
            else
            {
                Label1.Text = "用户名或密码错误";
            }
        }

        
        
       
    }
}